<div id="center_tieude">
    <img src="../../Picture/admin.ico"/>
    <h3>Danh Sách Khách Hàng</h3>        
</div> <!--end id center_tieude-->

<div id="timkiem_them">
<form action="" method="post">
    <select name="timkiem_khachhang">
        <option value="hoten">Tìm theo họ tên</option>
        <option value="tdn">Tìm theo tên đăng nhập</option>
    </select>
    <label style="float:left; margin:10px;">Từ khóa:</label>
    <input style="float:left; margin:10px;" type="search" name="key"/>
    <input style="float:left; margin:10px;" type="submit" name="timkiem" value="Tìm Kiếm"/>
</form>
</div><!--end id timkiem_them-->
<table border="1px" cellspacing="0px" width="700px">
  <tr>
      <th>
          ID
      </th>
      <th>
          Họ Tên
      </th>
      <th>
          Tên Đăng Nhập
      </th>
      <th>
          Ngày Sinh
      </th>
      <th>
          Giới Tính
      </th>
      <th>
          Địa Chỉ
      </th>
      <th>
          Email
      </th>
      <th>
          Số Điện Thoại
      </th>
  </tr>
  
   <?php
	  		if(isset($_GET['trang']))
			{
				$page=$_GET['trang'];
				$arr=thongtincanhan::GetAll($page,7);
				for($i=0;$i<count($arr);$i++)     
				{    
				?>  	
					  <tr>
                          <td>
							  <?php echo $arr[$i]->idcanhan;?>
                          </td>
                          <td>
                             <?php echo $arr[$i]->hoten;?>
                          </td>
                          <td>
                              <?php echo $arr[$i]->tendangnhap;?>
                          </td>
                          <td>
                              <?php echo $arr[$i]->ngaysinh;?>
                          </td>
                          <td>
                              <?php
                                if($arr[$i]->gioitinh==1)
                                    echo 'Nam';
                                else
                                    echo 'Nữ';	
                                ?>
                          </td>
                          <td>
                              <?php echo $arr[$i]->diachi;?>
                          </td>
                          <td>
                              <?php echo $arr[$i]->email;?>
                          </td>
                          <td>
                             <?php echo $arr[$i]->sodienthoai;?>
                          </td>
                          <td>
                              <a href="admin.php?obj=khachhang&act=delete&id=<?php echo $arr[$i]->tendangnhap;?>"><img title="Xóa khách hàng" alt="Xóa khách hàng" src="../../Picture/del.png"/></a>
                          </td>     
                     </tr>
     <?php
          		}
			}
			else
			{
				$page=1;
				$arr=thongtincanhan::GetAll($page,7);
				for($i=0;$i<count($arr);$i++)     
				{    
				?>  	
					 <tr>
                          <td>
							  <?php echo $arr[$i]->idcanhan;?>
                          </td>
                          <td>
                             <?php echo $arr[$i]->hoten;?>
                          </td>
                          <td>
                              <?php echo $arr[$i]->tendangnhap;?>
                          </td>
                          <td>
                              <?php echo $arr[$i]->ngaysinh;?>
                          </td>
                          <td>
                              <?php
                                if($arr[$i]->gioitinh==1)
                                    echo 'Nam';
                                else
                                    echo 'Nữ';	
                                ?>
                          </td>
                          <td>
                              <?php echo $arr[$i]->diachi;?>
                          </td>
                          <td>
                              <?php echo $arr[$i]->email;?>
                          </td>
                          <td>
                             <?php echo $arr[$i]->sodienthoai;?>
                          </td>
                          <td>
                              <a href="admin.php?obj=khachhang&act=delete&id=<?php echo $arr[$i]->tendangnhap;?>"><img title="Xóa khách hàng" alt="Xóa khách hàng" src="../../Picture/del.png"/></a>
                          </td>     
                     </tr>
     <?php
          		}
			}		
      ?>

</table><!--end class danhmuc-->
<div id="trang">
	<?php
		if(!isset($_GET["trang"]))
			$_GET["trang"]=1;
		if(isset($_GET["obj"])&&$_GET["obj"]=='khachhang')
		{
		$a = thongtincanhan::CountKH();
		$sotrang = ceil($a/7);
		$hientai = $_GET["trang"];
			for ($page = 1;(int)$page<=$sotrang;$page++ )
			{
				if($hientai != $page)
				{ echo "
					<a href='admin.php?obj=khachhang&trang=$page'>$page</a>";
				}
				else
				{
					echo "<b>".$page."</b>";
				}
			}
		}
		
?>
</div>